// -*- C++ -*------------------------------------------------------------------
// $Id: LigandSet.cc,v 1.2 2007-10-26 14:55:16 biocomp Exp $
//
//  Class:             LigandSet
//
//  Base Class(es):    -
//
//  Derived Class(es): -
//
//  Containing:        -
//
//  Author:            Silvio Tosatto, previous work: Marcus Pruemmer
//
//  Project Name:      Victor
//
//  Date:              02/02, previous work: 06/2000
//
//  Reviewed By:       <Name>
//
//  Description:       --
// 
//  ATTENTION:         This class is *NOT* finished yet.
//                     There are many methods which have only a head
//                     declaration and no code inside.
// ---------------------------------------------------------------------------

//Includes:
#include <LigandSet.h>
#include <Debug.h>
#include <IntCoordConverter.h>
#include <limits.h>
#include <float.h>

// Global constants, typedefs, etc. (to avoid):

using namespace Biopool;

// CONSTRUCTORS/DESTRUCTOR:
LigandSet::LigandSet()
{
  PRINT_NAME;
}

LigandSet::LigandSet(const LigandSet& orig)
{
  PRINT_NAME;
  this->copy(orig);
}

LigandSet::~LigandSet()
{ PRINT_NAME; }

void 
LigandSet::copy(const LigandSet& orig)
{
  PRINT_NAME;
  Polymer::copy(orig);
}

LigandSet* 
LigandSet::clone()
{
  LigandSet* tmp = new LigandSet;
  tmp->copy(*this);
  return tmp;
}

// OPERATORS:

LigandSet& 
LigandSet::operator=(const LigandSet& orig)
{
  PRINT_NAME;
  if (&orig != this)
    copy(orig);
  return *this;
}

void 
LigandSet::insertLigand(Ligand* g)
{  
  if( g->hasSuperior() )
    ERROR("Ligand does have a superior",exception);
  if ( g->getClassName() != "Ligand") 
    ERROR("LigandSet can only insert a Ligand",exception);
  Polymer::insertComponent( static_cast<Component*> (g) );
  setModified();
}


// HELPERS:

void 
LigandSet::resetBoundaries()
{
  vgVector3<double> tmpV(DBL_MAX-1,DBL_MAX-1,DBL_MAX-1);
  lowerBound = tmpV;
  upperBound = -tmpV;
  unsigned int sizeL = sizeLigand();
  for (unsigned int i = 0; i < sizeL; i++)
    for (unsigned int j = 0; j < 3; j++)
      {
	if (getLigand(i).getLowerBound()[j] < lowerBound[j])
	  lowerBound[j] = getLigand(i).getLowerBound()[j];
	if (getLigand(i).getUpperBound()[j] > upperBound[j])
	  upperBound[j] = getLigand(i).getUpperBound()[j];
      }
}




